package com.sfdcj.se.meta.field;

import java.util.HashMap;

import com.sforce.soap._2006._04.metadata.CustomField;

/*
 <fields>
 <fullName>Field1__c</fullName>
 <displayFormat>A-{0000}</displayFormat>
 <label>Autnumber</label>
 <type>AutoNumber</type>
 </fields>
 */

public class AutoNumberType extends FieldType {

	static final String TYPE = "AutoNumber";

	public String format;

	public AutoNumberType() {
		super();
	}

	public void appendXML() {
		buf.append("<displayFormat>" + format + "</displayFormat>");
		buf.append("<type>" + TYPE + "</type>");
	}

	@Override
	public String getTypeName() {
		return TYPE;
	}

	@Override
	public Object clone() {
		return new AutoNumberType();
	}

	@Override
	public void setAttributes(HashMap<String, String> attributes) {
		format = attributes.get("format");
	}

	@Override
	public CustomField toCustomField() {
		CustomField field = new CustomField();
		field.setFullName(objectFullname + "." + fullname);
		field.setLabel(label);
		field.setDisplayFormat(format);
		field.setType(com.sforce.soap._2006._04.metadata.FieldType.AutoNumber);
		return field;
	}		

}
